<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="core/include/global.asp" -->
<% Response.Expires = 0 
   if request.ServerVariables("REQUEST_METHOD") = "POST" then 
		 ' define variables and COM objects
		 'dim ado_stream
		 'dim xml_dom
		 'dim xml_file1
		 dim fld
		 	for each fld in request.form
		 		writeln(p("you upped '"&request.form.key(fld)&"' with value '"&request.form.item(fld)&"'"))
			next
'	
'		 ' create Stream Object
'		 set ado_stream = Server.CreateObject("ADODB.Stream")
'		 ' create XMLDOM object and load it from request ASP object
'		 set xml_dom = Server.CreateObject("MSXML2.DOMDocument")
'		 xml_dom.load(request)
'		 ' retrieve XML node with binary content
'		 set xml_file1 = xml_dom.selectSingleNode("root/file1")
'	
'		 ' open stream object and store XML node content into it   
'		 ado_stream.Type = 1  ' 1=adTypeBinary 
'		 ado_stream.open 
'		 ado_stream.Write xml_file1.nodeTypedValue
'		 ' save uploaded file
'		 ado_stream.SaveToFile "c:\tmp\upload1.doc",2  ' 2=adSaveCreateOverWrite 
'		 ado_stream.close
'	
'		 ' destroy COM object   
'		 set ado_stream = Nothing 
'		 set xml_dom = Nothing
'		 ' write message to browser
'		 Response.Write "Upload successful!"
	 else 
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Iframe Ajax</title>
	<script type="text/javascript" src="webtoolkit.aim.js"></script>
	<script type="text/javascript">
		function startCallback() {
			// make something useful before submit (onStart)
			return true;
		}

		function completeCallback(response) {
			// make something useful after (onComplete)
			document.getElementById('nr').innerHTML = parseInt(document.getElementById('nr').innerHTML) + 1;
			document.getElementById('r').innerHTML = response;
		}
	</script>
</head>

<body>

	<form action="test.asp" method="post" onsubmit="return AIM.submit(this, {'onStart' : startCallback, 'onComplete' : completeCallback})">
		<div><label>Name:</label> <input type="text" name="form[name]" /></div>
		<div><label>File:</label> <input type="file" name="form[file]" /></div>
		<div><input type="submit" value="SUBMIT" /></div>
	</form>

	<hr/>

	<div># of submited forms: <span id="nr">0</span></div>
	<div>last submit response (generated by form action - index.php file): <pre id="r"></pre></div>

</body>
</html>
<% end if %>
